# https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=python&fenlei=256&rsv_pq=b9ab8b180000772c&rsv_t=4b33aGKX1X2ul3JkUg3yZDjMPC3hc4YNw1EltYS7AHNI%2B4S4x2asw8Qqa58&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_sug3=12&rsv_sug1=15&rsv_sug7=101&rsv_sug2=0&rsv_btype=i&inputT=6080&rsv_sug4=8081

import requests

# url = "https://www.baidu.com/s?wd=python"
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
# }
#
# response = requests.get(url, headers=headers)
#
# with open('baidu.html', 'wb') as f:
#     f.write(response.content)


url = "https://www.baidu.com/s?"

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
}

# 构建参数字典
data = {
    'wd': 'python'
}

response = requests.get(url, headers=headers, params=data)

print(response.url)
with open('baidu1.html', 'wb') as f:
    f.write(response.content)